function ImgPreloader(callback){

    var $allimgs = $('img[preload-src]');
    if(!$allimgs || !$allimgs.length){

        callback({
            percentage: 1
        })
        return;
    }

    var img_total_count = $allimgs.length,
        img_loaded_count = 0;

    var onImgLoaded = function(e){

        // js 是单线程，不需要考虑并发
        img_loaded_count++;

        console.log(img_loaded_count);

        callback({
            percentage: img_loaded_count/img_total_count
        })
    }

    $allimgs.each(function(idx,img){

        img.onload = onImgLoaded;
        img.src = img.getAttribute('preload-src');
    })
};

function ImgLazyloader(){

    var $allimgs = $('img[lazy-src]');

    if($allimgs.length == 0) {
        return
    }

    $allimgs.each(function(idx,img){

        //var newImage = new Image();
        //newImage.onload = function(){
        // img.src = this.src
        //}
        //
        //newImage.src = img.getAttribute('lazy-src');

        img.src = img.getAttribute('lazy-src');
    })
}
